{% load i18n %}
{% load staticfiles %}

<!DOCTYPE html>
<html lang="en">
	<head>
	<base href="<%=basePath%>"><!-- jsp文件头和头部 -->
	{% include 'main/top.html' %}
	<title>列表首页</title>
	</head>
<body>
		
<div class="container-fluid" id="main-container">


<div id="page-content" class="clearfix">
						
  <div class="row-fluid">

	<div class="row-fluid">
	
			<!-- 检索  -->
			<form action="/main/main_defaultlist" method="get" name="Form" id="Form">
			{% csrf_token %}
			<table>
				<tr>
					<td>
						<span class="input-icon">
							<input autocomplete="off" id="nav-search-input" type="text" name="KEYWORD" placeholder="这里输入关键词" />
							<i id="nav-search-icon" class="icon-search"></i>
						</span>
					</td>
					<td style="vertical-align:top;"> 
					 	<select class="chzn-select" name="STATUS" id="STATUS" data-placeholder="请选择状态" style="vertical-align:top;width: 120px;">
							<option value=""></option>
							<option value="">全部</option>
							<option value="1">有效</option>
							<option value="2">无效</option>
					  	</select>
					</td>
					<td style="vertical-align:top;"><button class="btn btn-mini btn-light" onclick="search();"  title="检索"><i id="nav-search-icon" class="icon-search"></i></button></td>
					
					<td style="vertical-align:top;"><a class="btn btn-mini btn-light" onclick="toExcel();" title="导出到EXCEL"><i id="nav-search-icon" class="icon-download-alt"></i></a></td>
					
				</tr>
			</table>
			<!-- 检索  -->
		
		
			<table id="table_report" class="table table-striped table-bordered table-hover">
				
				<thead>
					<tr>
						<th class="center">
						<label><input type="checkbox" id="zcheckbox" /><span class="lbl"></span></label>
						</th>
						<th class="center">序号</th>
						<th class="center">菜单名称</th>
						<th class="center">菜单编码</th>
						<th class="center">父节点编码</th>
						<th class="center">操作</th>
					</tr>
				</thead>
										
				<tbody>
					{% for menu_top in menu_dict %}
							<tr>
								<td class='center' style="width: 30px;">
									<label><input type='checkbox' name='ids' value="{{menu_top.id}}" /><span class="lbl"></span></label>
								</td>
								<td class='center' style="width: 30px;">{{menu_top.id}}</td>
								<td>{{menu_top.name}}</td>
								{% if menu_top.url != None %}
									<td>{{menu_top.url}}</td>
								{% elif menu_top.url == None %}
									<td></td>
								{% endif %}
								
								<td>{{menu_top.parent_id}}</td>
								<td style="width: 30px;" class="center">
									<div class='hidden-phone visible-desktop btn-group'>
									
									
										<span class="label label-large label-grey arrowed-in-right arrowed-in"><i class="icon-lock" title="无权限"></i></span>
									
										<div class="inline position-relative">
										<button class="btn btn-mini btn-info" data-toggle="dropdown"><i class="icon-cog icon-only"></i></button>
										<ul class="dropdown-menu dropdown-icon-only dropdown-light pull-right dropdown-caret dropdown-close">
										 
											<li><a style="cursor:pointer;" title="编辑" onclick="edit('${var.TEXTMSG_ID}');" class="tooltip-success" data-rel="tooltip" title="" data-placement="left"><span class="green"><i class="icon-edit"></i></span></a></li>
											 
											 
											<li><a style="cursor:pointer;" title="删除" onclick="del('${var.TEXTMSG_ID}');" class="tooltip-error" data-rel="tooltip" title="" data-placement="left"><span class="red"><i class="icon-trash"></i></span> </a></li>
											 
										</ul>
										</div>
									</div>
								</td>
							</tr>
					{% endfor %}
							<tr>
								<td colspan="100" class="center">您无权查看</td>
							</tr>
						<tr class="main_info">
							<td colspan="100" class="center" >没有相关数据</td>
						</tr>
					</c:otherwise>
				</c:choose>
					
				
				</tbody>
			</table>
			
		<div class="page-header position-relative">
		<table style="width:100%;">
			<tr>
				<td style="vertical-align:top;">
					{% for item in sub_item %} 
						{% if item.type == 'add_type' %}
							<a class="btn btn-small btn-success" onclick="add();">新增</a>
						{% endif %}
						{% if item.type == 'edit_type' %}
							<a class="btn btn-small btn-success" onclick="add();">编辑</a>
						{% endif %}
						{% if item.type == 'del_type' %}
							<a class="btn btn-small btn-danger" onclick="makeAll('确定要删除选中的数据吗?');" title="批量删除" ><i class='icon-trash'></i></a>
						{% endif %}
						
						
					{% endfor %}
						
				</td>
				<td style="vertical-align:top;">
					<div class="pagination" style="float: right;padding-top: 0px;margin-top: 0px;">
						<ul>
							<li>
								<a>共
									<font color="red">4</font>条
								</a>
							</li>
							<li><input type="number" value="" id="toGoPage" style="width:50px;text-align:center;float:left" placeholder="页码"></li>
							<li style="cursor:pointer;"><a onclick="toTZ();" class="btn btn-mini btn-success">跳转</a></li>
							<li><a>首页</a></li>
							<li style="cursor:pointer;"><a  onclick="nextpage();">上页</a></li>
							<li><a><font color="#808080">1</font></a></li>
							<li><a>下页</a></li>
							<li><a>尾页</a></li>
							<li><a>第1页</a></li>
							<li><a>共1页</a></li>
							<li><select title="显示条数" style="width:55px;float:left;" onchange="changeCount(this.value)">
							<option value="10">10</option>
							<option value="10">10</option>
							<option value="20">20</option>
							<option value="30">30</option>
							<option value="40">40</option>
							<option value="50">50</option>
							<option value="60">60</option>
							<option value="70">70</option>
							<option value="80">80</option>
							<option value="90">90</option>
							<option value="99">99</option>
							</select>
							</li>
						</ul>
					</div>
				</td>
			</tr>
		</table>
		</div>
		</form>
	</div>
 
 
 
 
	<!-- PAGE CONTENT ENDS HERE -->
  </div><!--/row-->
	
</div><!--/#page-content-->
</div><!--/.fluid-container#main-container-->
		
		<!-- 返回顶部  -->
		<a href="#" id="btn-scroll-up" class="btn btn-small btn-inverse">
			<i class="icon-double-angle-up icon-only"></i>
		</a>
		
		<!-- 引入 -->
		<script type="text/javascript">window.jQuery || document.write("<script src='static/js/jquery-1.9.1.min.js'>\x3C/script>");</script>
		<script src="/static/js/bootstrap.min.js"></script>
		<script src="/static/js/ace-elements.min.js"></script>
		<script src="/static/js/ace.min.js"></script>
		
		<script type="text/javascript" src="/static/js/chosen.jquery.min.js"></script><!-- 下拉框 -->
		<script type="text/javascript" src="/static/js/bootstrap-datepicker.min.js"></script><!-- 日期框 -->
		<script type="text/javascript" src="/static/js/bootbox.min.js"></script><!-- 确认窗口 -->
		<!-- 引入 -->
		<script type="text/javascript" src="/static/js/jquery.tips.js"></script><!--提示框-->
		<script type="text/javascript">
		function nextPage(page){ 
			top.jzts();	
			if(true && document.forms[0]){
				var url = document.forms[0].getAttribute("action");
				if(url.indexOf('?')>-1)
				{
					url += "&currentPage=";
				}else{
					url += "?currentPage=";
				}
				url = url + page + "&showCount=10";
				document.forms[0].action = url;
				document.forms[0].submit();
			}else{
				var url = document.location+'';
				if(url.indexOf('?')>-1){
					if(url.indexOf('currentPage')>-1){
						var reg = /currentPage=\d*/g;
						url = url.replace(reg,'currentPage=');
					}else{
						url += "&currentPage=";
					}
				}else{
					url += "?currentPage=";
				}
				url = url + page + "&showCount=10";
				document.location = url;
			}
		}
		function changeCount(value){ 
			top.jzts();	
			if(true && document.forms[0]){
				var url = document.forms[0].getAttribute("action");
				if(url.indexOf('?')>-1){url += "&currentPage=";}
				else{url += "?currentPage=";}
				url = url + "1&showCount="+value;
				document.forms[0].action = url;
				document.forms[0].submit();
			}else{
				var url = document.location+'';
				if(url.indexOf('?')>-1){
					if(url.indexOf('currentPage')>-1){
						var reg = /currentPage=\d*/g;
						url = url.replace(reg,'currentPage=');
					}else{
						url += "1&currentPage=";
					}
				}else{url += "?currentPage=";}
				url = url + "&showCount="+value;
				document.location = url;
			}
		}
		function toTZ(){
			var toPaggeVlue = document.getElementById("toGoPage").value;
			if(toPaggeVlue == ''){
				document.getElementById("toGoPage").value=1;
				return;
			}
			if(isNaN(Number(toPaggeVlue))){
				document.getElementById("toGoPage").value=1;
				return;
			}
			nextPage(toPaggeVlue);
		}
		
		
		$(top.hangge());
		
		//检索
		function search(){
			top.jzts();
			$("#Form").submit();
		}
		
		//新增
		function add(){
			 top.jzts();
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="新增";
			 diag.URL = '/main/main_defaultedit';
			 diag.Width = 600;
			 diag.Height = 390;
			 diag.CancelEvent = function(){ //关闭事件
				 if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
					 
					 if('${page.currentPage}' == '0'){
						 top.jzts();
						 setTimeout("self.location=self.location",100);
					 }else{
						 nextPage(34);
					 }
				}
				diag.close();
			 };
			 diag.show();
		}
		
		//删除
		function del(Id){
			bootbox.confirm("确定要删除吗?", function(result) {
				if(result) {
					top.jzts();
					var url = "<%=basePath%>textmsg/delete.do?TEXTMSG_ID="+Id+"&tm="+new Date().getTime();
					$.get(url,function(data){
						nextPage(1);
					});
				}
			});
		}
		
		//修改
		function edit(Id){
			 top.jzts();
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="编辑";
			 diag.URL = '<%=basePath%>textmsg/goEdit.do?TEXTMSG_ID='+Id;
			 diag.Width = 600;
			 diag.Height = 390;
			 diag.CancelEvent = function(){ //关闭事件
				 if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
					 nextPage(3);
				}
				diag.close();
			 };
			 diag.show();
		}
		</script>
		
		<script type="text/javascript">
		
		$(function() {
			
			//下拉框
			$(".chzn-select").chosen(); 
			$(".chzn-select-deselect").chosen({allow_single_deselect:true}); 
			
			//日期框
			$('.date-picker').datepicker();
			
			//复选框
			$('table th input:checkbox').on('click' , function(){
				var that = this;
				$(this).closest('table').find('tr > td:first-child input:checkbox')
				.each(function(){
					this.checked = that.checked;
					$(this).closest('tr').toggleClass('selected');
				});
					
			});
			
		});
		
		
		//批量操作
		function makeAll(msg){
			bootbox.confirm(msg, function(result) {
				if(result) {
					var str = '';
					for(var i=0;i < document.getElementsByName('ids').length;i++)
					{
						  if(document.getElementsByName('ids')[i].checked){
						  	if(str=='') str += document.getElementsByName('ids')[i].value;
						  	else str += ',' + document.getElementsByName('ids')[i].value;
						  }
					}
					if(str==''){
						bootbox.dialog("您没有选择任何内容!", 
							[
							  {
								"label" : "关闭",
								"class" : "btn-small btn-success",
								"callback": function() {
									//Example.show("great success");
									}
								}
							 ]
						);
						
						$("#zcheckbox").tips({
							side:3,
				            msg:'点这里全选',
				            bg:'#AE81FF',
				            time:8
				        });
						
						return;
					}else{
						if(msg == '确定要删除选中的数据吗?'){
							top.jzts();
							$.ajax({
								type: "POST",
								url: '<%=basePath%>textmsg/deleteAll.do?tm='+new Date().getTime(),
						    	data: {DATA_IDS:str},
								dataType:'json',
								//beforeSend: validateData,
								cache: false,
								success: function(data){
									 $.each(data.list, function(i, list){
											nextPage(4);
									 });
								}
							});
						}
					}
				}
			});
		}
		
		//导出excel
		function toExcel(){
			window.location.href='<%=basePath%>textmsg/excel.do';
		}
		$(top.hangge());
		</script>
		
	</body>
</html>

